﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Webdiyer.AspNetCore;
using PlatformNetCore.Entity;
using PlatformNetCore.IRepository;

namespace PlatformNetCore.Repository
{
    public class JobsRepository : Repository<Jobs>, IJobsRepository
    {
        public JobsRepository(PlatformContext dbContext) : base(dbContext)
        {

        }

        public override PagedList<Jobs> GetPagedList(int pageIndex, int pageSize, Expression<Func<Jobs, bool>> predicate)
        {
            return _dbContext.Jobs.Where(predicate).OrderByDescending(m => m.AddDate).ToPagedList(pageIndex, pageSize);
        }
        public override PagedList<Jobs> GetPagerList(int pageIndex, int pageSize, Expression<Func<Jobs, bool>> predicate)
        {
            return _dbContext.Jobs.Where(predicate).OrderBy(m => m.SortNo).ThenByDescending(k => k.PublishDate).ToPagedList(pageIndex, pageSize);
        }

        public override IEnumerable<Jobs> GetList(Expression<Func<Jobs, bool>> predicate)
        {
            return _dbContext.Jobs.Where(predicate).OrderBy(m => m.SortNo).ThenByDescending(k => k.PublishDate);
        }
    }
}
